define(['app'], function(app) {
	'use strict';

	//实例化方法
	var factory = function(Http) {
         function get_data_issuediscount(result){
         	if(false){
         		result='{"success": true,"msg": "","result": {"coupon": ['+
            '{"id": "001","cpns_name": "10元优惠券","cpns_prefix": "123456789","cpns_id": "001","amount": 10,"issue_count": 1000,"draw_count": 900,"termofvalidity": "2017/01/01-2017/12/31"},'+
            '{"id": "002","cpns_name": "20元优惠券","cpns_prefix": "223456789","cpns_id": "001","amount": 20,"issue_count": 1000,"draw_count": 900,"termofvalidity": "2017/01/01-2017/12/31"}],"invalid_coupon": ['+
            '{"id": "001","cpns_name": "10元优惠券","cpns_prefix": "123456789","cpns_id": "001","amount": 10,"issue_count": 1000,"draw_count": 900,"termofvalidity": "2016/01/01-2016/12/31"},'+
            '{"id": "002","cpns_name": "20元优惠券","cpns_prefix": "223456789","cpns_id": "001","amount": 20,"issue_count": 1000,"draw_count": 900,"termofvalidity": "2016/01/01-2016/12/31"}]},"session": "7311da98bd0f18eb15a96bcb263f4153"}';
            return JSON.parse(result);
         	}else{
         		return result;
         	}
        }
         
		//返回信息
		return {
			get_issuediscount: function(nPage,callback,calldone) {
				Http.post({
					method:'member.coupon.releaselist',
					pagelimit:10,
					nPage:nPage
				}, function(result) {
					//函数回调
					if(callback)
						callback(get_data_issuediscount(result).result);
				},function(e){
					
				},function(){
					if(calldone)
					   	calldone();
				});
			},
			//删除优惠券
			del: function(id,callback) {
				//post请求
				Http.post({
					method:'member.coupon.delete',
					id:id
				}, function(result) {
					//函数回调
					if(callback)
						callback(result);
				},function(e){
					
				},function(){
					
				});
			},
		};
	}

	factory.$inject = ['Http'];
	return app.registerService("Issuediscount", factory);
});
